import 'package:flutter/material.dart';

/**
 * ListView
 */
main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(primaryColor: Colors.teal, cardColor: Colors.orange),
      debugShowCheckedModeBanner: false,
      home: HYHomePage(),
    );
  }
}

class HYHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Flutter Demo'),
      ),
      body: Container(
        height: 300,
        child: ListView.separated(
            itemBuilder: (BuildContext ctx, int index) {
              return Text(
                'Hello Flutter: $index',
                style: TextStyle(fontSize: 20),
              );
            },
            separatorBuilder: (BuildContext ctx, int index) => Divider(
              color: Colors.red,
              height: 30,
              indent: 30,
              endIndent: 30,
              thickness: 10,
            ),
            itemCount: 10),
      ),
    );
  }
}

class ListViewDemo2 extends StatelessWidget {
  const ListViewDemo2({
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ListView.builder(
        itemCount: 100,
        itemExtent: 60,
        itemBuilder: (BuildContext ctx, int index) {
          return Text(
            'Hello Flutter: $index',
            style: TextStyle(fontSize: 20),
          );
        });
  }
}

class ListViewDemo1 extends StatelessWidget {
  const ListViewDemo1({
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ListView(
//        scrollDirection: Axis.horizontal,
//        itemExtent: 80,
//      reverse: true,
//        primary: false,
      children: List.generate(
          100,
              (index) => ListTile(
            leading: Icon(Icons.people),
            trailing: Icon(Icons.delete),
            title: Text('联系人${index + 1}'),
            subtitle: Text('联系人电话号码:188882322$index'),
          )),
    );
  }
}
